package com.ry.bhwktapp.home.ui

interface Factory {
    fun produce()
}

/**
 * 美食工厂，生产美食
 */
class FoodFactory: Factory{
    override fun produce() {
        println("生产美食")
    }
}

/**
 * 实现接口并委托给FoodFactory
 */
class Action1(factory: FoodFactory):Factory by factory

/**
 * 实现接口自己重写生产美食的方法
 */
class Action2:Factory by FoodFactory(){
    override fun produce() {
        println("自己生产美食")
    }
}

fun main() {

    val action1 = Action1(FoodFactory())
    action1.produce()

    val action2 = Action2()
    action2.produce()

}